//
//  OMCollectionSearchItemCollectHeader.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/4/21.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMCollectionSearchItemCollectHeader.h"
#import "MainConfigure.h"
@interface OMCollectionSearchItemCollectHeader()

@end

@implementation OMCollectionSearchItemCollectHeader
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    [self configure];
    return self;
}

- (void)configure
{

    _imageView = [[UIImageView alloc]init];
    [self addSubview:_imageView];
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(50)));
        make.centerY.equalTo(self.mas_centerY);
    }];

    _elementLabel = [UILabel new];
    _elementLabel.font = SM_CFont(27);
    _elementLabel.textColor = HEXCOLOR(@"#777777");
    [self addSubview:_elementLabel];
    [_elementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView.mas_right).offset(SM_SIZE(20));
        make.centerY.equalTo(self.mas_centerY);
    }];

    _rightButton = [UIButton new];
    [self addSubview:_rightButton];
    [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(SM_SIZE(-50)));
        make.centerY.equalTo(self.mas_centerY);
    }];
    @weakify(self);
    [[_rightButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        @strongify(self);
        if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectRightButtonOnHeader:atSection:)]) {
            [self.delegate didSelectRightButtonOnHeader:self atSection:self.section];
        }
    }];

}

@end
